package me.zhengjie.modules.weixin.message.custom;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;

import java.util.List;

public class CustomNewsMessage extends AbstractCustomMessage {

    public CustomNewsMessage() {
        setMsgtype("news");
    }

    public CustomNewsMessage(NewsDTO.ArticlesDTO articles) {
        this();
        this.news = new NewsDTO();
        this.news.setArticles(Lists.newArrayList(articles));
    }

    private NewsDTO news;

    public NewsDTO getNews() {
        return news;
    }

    public void setNews(NewsDTO news) {
        this.news = news;
    }

    public static class NewsDTO {
        @JsonProperty("articles")
        private List<ArticlesDTO> articles;

        public List<ArticlesDTO> getArticles() {
            return articles;
        }

        public void setArticles(List<ArticlesDTO> articles) {
            this.articles = articles;
        }

        public static class ArticlesDTO {
            /**
             * title : Happy Day
             * description : Is Really A Happy Day
             * url : URL
             * picurl : PIC_URL
             */

            @JsonProperty("title")
            private String title;
            @JsonProperty("description")
            private String description;
            @JsonProperty("url")
            private String url;
            @JsonProperty("picurl")
            private String picurl;

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }

            public String getDescription() {
                return description;
            }

            public void setDescription(String description) {
                this.description = description;
            }

            public String getUrl() {
                return url;
            }

            public void setUrl(String url) {
                this.url = url;
            }

            public String getPicurl() {
                return picurl;
            }

            public void setPicurl(String picurl) {
                this.picurl = picurl;
            }
        }
    }

}
